var tools = require('../tools/tools.js'),
    app = getApp();
Page({


  data: {

  },

  onLoad: function (options) {
    console.log(app.APIKEY);
      let id = options.id,
          DetailUrl = app.MOVIEDETAILURL+id+app.APIKEY;
          tools.getMovieAsyncData(DetailUrl,this.renderDetail)
        

  },
  onTopreviewImage:function(){
     console.log(this.data.data.photos[0]);
    wx.previewImage({
      current: this.data.data.photos[0], // 当前显示图片的http链接
      urls: this.data.data.photos// 需要预览的图片http链接列表
    })
  },
  renderDetail:function(res){
      console.log(res.data);
       console.log(tools.getArrValue(res.data.directors,"name").join());
      var data = res.data,
             movieDetail ={
             title:data.title,
             original_title:data.original_title,
             img:data.images.large,
             directors:tools.getArrValue(data.directors,"name").join(),
             writers:tools.getArrValue(data.writers,"name").join('/'),
             performerName:tools.getArrValue(data.casts,"name").join('/'),
             tags:data.tags.join('/'),
             cuntries:data.countries.join('/'),
             languages:data.languages.join('/'),
             durations:data.durations.join(),
             pubdates:data.pubdates.join(),
             rating:{rating:data.rating.average},
             summary:data.summary,
             performer:data.casts,
             photos:tools.getArrValue(data.photos,"image")



    };
     var starClass={
      rate:Number(data.rating.average)
     }
    this.setData({
     data: movieDetail,
     item:starClass
    })


  }

 
})